GFX.clear();
rect = GFX.createRect({ x: 100, y: 100, width:100, height: 100 });
rect.setFill([255, 0, 0, .5]);

// adds a function to the LAYER 0, it will be called in every frame
LAYER0.addTo("basicanim", function()    {
    
    var speed = 10;
    // calculates the new position based on the FRAMECOUNTER
    var posx = (FRAMECOUNTER % 20)*speed;

    // transforms the rect
    rect.setTransform({ dx: posx });

});